import DApp from '../config/configuration.js';

const API = {
	async usdt(){
		let {
			usdt
		} = this.meta.methods;
		let res = await usdt().call()
		return res;
	},
	async infos() {
		let {
			infos
		} = this.meta.methods;
		let {
			account
		} = this;
		let res = await infos().call({
			from:account,
		})
		return res;
	},
	async invest(nodeIndex, parent) {//质押
	console.log(nodeIndex, parent);
		let {
			invest
		} = this.meta.methods;
		let {
			account
		} = this;
		let res = await invest(nodeIndex,parent).send({
			from:account,
			gas:0
		})
		return res;
	},
}

export default {
	meta: null,
	account: null,
	web3: null,
	async init() {
		let obj = await DApp.idoInit();
		let {
			meta,
			account,
			web3
		} = obj;
		this.meta = meta;
		this.account = account;
		this.web3 = web3;
		return this;
	},
	...API
}